package com.ft.oa.config;


import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

@Configuration
public class CaffeineConfigure {

    // 过期时间 毫秒
    @Value("${jwt.expiration}")
    private Long expiration;

    @Bean
    public Cache<String, Object> caffeineCache() {
        return Caffeine.newBuilder()
            .initialCapacity(100)
            .maximumSize(1000)
            .expireAfterWrite(expiration, TimeUnit.MILLISECONDS)
            .build();
    }
}
